package top.lyjwn.ajui.widget.list.refresh;

import android.content.Context;
import android.util.AttributeSet;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import androidx.annotation.ColorRes;

import static com.scwang.smartrefresh.layout.util.SmartUtil.getColor;

/**
 * 刷新
 *
 * @author luoyujie
 */
public class ISmartRefreshLayout extends SmartRefreshLayout {
    public ISmartRefreshLayout(Context context) {
        super(context);
    }

    public ISmartRefreshLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ISmartRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private int[] mPrimaryColorsToHeader;

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (mPrimaryColorsToHeader != null) {
            if (mRefreshHeader != null) {
                final int[] colors = new int[mPrimaryColorsToHeader.length];
                for (int i = 0; i < mPrimaryColorsToHeader.length; i++) {
                    colors[i] = getColor(getContext(), mPrimaryColorsToHeader[i]);
                }
                mRefreshHeader.setPrimaryColors(colors);
            }

        }
        if (mPrimaryColors!=null){
            if (mRefreshFooter != null) {
                mRefreshFooter.setPrimaryColors(mPrimaryColors);
            }
        }
    }

    public void setPrimaryColorsIdToHeader(@ColorRes int... primaryColorId) {
        this.mPrimaryColorsToHeader = primaryColorId;
    }


}
